package com.dci.service.impl.schedule;

import com.dci.context.Config;
import com.dci.dao.pms.schedule.ProgressUnitMapper;
import com.dci.dao.pms.schedule.ProjectTeamMapper;
import com.dci.model.schedule.ProgressUnit;
import com.dci.model.schedule.ProjectTeamManagement;
import com.dci.result.ResultInfo;
import com.dci.result.ResultUtil;
import com.dci.service.schedule.ProjectTeamService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * All rights Reserved, Designed By 姑苏区政府大数据中心
 *
 * @version V1.0
 * @Title: null.java
 * @Package com.dci.service.impl.schedule
 * @Description: 项目组管理实现类
 * @author: 张星亮
 * @date: 2019/2/25
 * @Copyright: 2019 姑苏区政府大数据中心. All rights reserved.
 * 注意：本内容仅限于姑苏区政府大数据中心内部传阅，禁止外泄以及用于其他的商业目
 */
@Service
public class ProjectTeamServiceImpl implements ProjectTeamService {
    @Resource
    private ProjectTeamMapper projectTeamMapper;

    @Resource
    private ProgressUnitMapper progressUnitMapper;

    /**
     * 新增
     *
     * @param projectTeamManagement
     * @return
     */
    @Override
    public ResultInfo add(ProjectTeamManagement projectTeamManagement) {
        int i = projectTeamMapper.insert(projectTeamManagement);
        if (i > 0) {
            return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
        }
        return ResultUtil.createSuccess(Config.MESSAGE, 911, null);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Override
    public ResultInfo delete(String id) {
        int i = projectTeamMapper.delete(id);
        if (i > 0) {
            return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
        }
        return ResultUtil.createSuccess(Config.MESSAGE, 911, null);
    }

    /**
     * 修改
     *
     * @param projectTeamManagement
     * @return
     */
    @Override
    public ResultInfo edit(ProjectTeamManagement projectTeamManagement) {
        int i = projectTeamMapper.update(projectTeamManagement);
        if (i > 0) {
            return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
        }
        return ResultUtil.createSuccess(Config.MESSAGE, 911, null);
    }

    /**
     * 查询
     *
     * @return
     */
    @Override
    public List<ProjectTeamManagement> select() {
        return projectTeamMapper.select();
    }

    /**
     * 获取所有建设单位
     *
     * @return
     */
    @Override
    public List<ProgressUnit> selectUnit() {
        List<ProgressUnit> list = progressUnitMapper.selectUnit();
        return progressUnitMapper.selectUnit();
    }
}
